package B刷题.B链表问题;

/**
 * @author wei.zhao
 * @description: 程序员代码面试指南：打印两个有序链表的公共部分
 * @date 2022/12/12 16:11
 */
public class Code01_打印两个有序链表的公共部分 {

    public static void printCommonpart(Node head1, Node head2) {
        while (head1 != null && head2 != null && head1.value != head2.value) {
          if (head1.value>head2.value){
              head1=head1.next;
          }else{
              head2=head2.next;
          }
        }
        if (null==head1||null==head2){
            return;
        }
        while (head1!=null){
            System.out.println(head1.value);
            head1=head1.next;
        }
    }

}
